<!DOCTYPE html>
<html>
<head>
  <meta charset=utf-8>
  <meta name=viewport content="width=device-width,initial-scale=1">
  <title>代理后台</title>
  <meta name=keywords content="">
  <meta name=description content="">
  <link rel="shortcut icon" href=./favicon.ico type=image/x-icon>
  <link href=static/css/public.css rel=stylesheet>
</head>
<body class=red-bg>
<div id=app></div>
</body>
<script>//步骤一:创建异步对象
var ajax = new XMLHttpRequest()
//步骤二:设置请求的url参数,参数一是请求的类型,参数二是请求的url,可以带参数,动态的传递参数starName到服务端
ajax.open('get', 'http://127.0.0.1:8085/api/site/getInfo.do')
// ajax.open('get', 'http://localhost:8070/api/site/getInfo.do')
//步骤三:发送请求
ajax.send()
//步骤四:注册事件 onreadystatechange 状态改变就会调用
ajax.onreadystatechange = function () {
  if (ajax.readyState == 4 && ajax.status == 200) {
    //步骤五 如果能够进到这个判断 说明 数据 完美的回来了,并且请求的页面是存在的
    var styleName = JSON.parse(ajax.responseText).data.siteColor
    if (styleName == 'black') {
      document.getElementsByTagName('body')[0].className = 'black-bg'
    } else {
      document.getElementsByTagName('body')[0].className = 'red-bg'
    }
  }
}</script>
</html>
